package com.kmxd.ams.app.event.archive.command;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kmxd.ams.client.archive.IArchiveTypeSvc;
import com.kmxd.ams.core.common.constant.CacheConst;
import com.kmxd.ams.core.util.RedisUtils;
import com.kmxd.ams.infra.archive.entity.ArchiveType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * count arch number
 *
 * @author nickbi
 */
@Slf4j
@RequiredArgsConstructor
@Component
public class ArchTypeCountCmd {
  private final IArchiveTypeSvc archiveTypeSvc;
  private final RedisUtils redisUtils;

  public void count() {
    long count = archiveTypeSvc.count(Wrappers.lambdaQuery());
    redisUtils.set(CacheConst.CACHE_PREFIX_ARCH_NUMBER, count);
  }
}
